package org.jod.spike.swing;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class MultipleFrame extends JFrame{

	/**
     * 
     */
    private static final long serialVersionUID = 1L;

    /**
	 * @param args
	 */
	public static void main(String[] args) {
		
		new MultipleFrame();
	}
	
	/**
	 * 
	 */
	public MultipleFrame() {
		
		super("MAIN FRAME");
		
		
		setLayout(new BorderLayout());
		
		MioPanel productPanel = new MioPanel(new MiaLabel("productPanel"));
		MioPanel transactionPanel = new MioPanel(new MiaLabel("transactionPanel"));
		MioPanel findProductPanel = new MioPanel(new MiaLabel("findProductPanel"));
		MioPanel paymentPanel = new MioPanel(new MiaLabel("paymentPanel"));
		
        JPanel topPanel = new JPanel();
        topPanel.setLayout(new BorderLayout());
        topPanel.add(productPanel, BorderLayout.LINE_START);
        topPanel.add(transactionPanel, BorderLayout.LINE_END);
        topPanel.setBorder(BorderFactory.createLineBorder(Color.black));
        add(topPanel, BorderLayout.PAGE_START);
               
        JPanel controlPanel = new JPanel();
        controlPanel.setLayout(new BorderLayout());
        controlPanel.add(findProductPanel, BorderLayout.LINE_START);
        controlPanel.add(paymentPanel, BorderLayout.LINE_END);
        controlPanel.setBorder(BorderFactory.createLineBorder(Color.black));
        add(controlPanel, BorderLayout.PAGE_END);
		
		
		setDefaultLookAndFeelDecorated(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //_frame.getContentPane().add(_panel);
        setSize(1024, 768);
        setLocationRelativeTo(null);
        setResizable(false);
        setVisible(true);
        
	}
	
	class MiaLabel extends JLabel {
		
		/**
         * 
         */
        private static final long serialVersionUID = 1L;
        private String _testo;
		private Font _font;

		public MiaLabel(String testo) {
			_testo = testo;
			 _font = new Font("Verdana", Font.BOLD, 24);
			 
			 setFont(_font);
			 setForeground(Color.RED );
			 setText(_testo);
			 
		}
		
		
	}
	
	class MioPanel extends JPanel {
		

		/**
         * 
         */
        private static final long serialVersionUID = 1L;
        private JLabel _label;

		/**
		 * @param aLabel
		 */
		public MioPanel(JLabel aLabel) {
			
			
			
			_label = aLabel;
			
	        JPanel controlPanel = new JPanel();
	        controlPanel.setLayout(new BorderLayout());
	        controlPanel.add(_label, BorderLayout.NORTH);
	        controlPanel.add(new MiaLabel("MIa label 2"), BorderLayout.CENTER);
	        add(controlPanel, BorderLayout.PAGE_END);			
			
	
			setSize(400, 400);
			setBorder(BorderFactory.createLineBorder(Color.black));
			
		}
	}

}
